package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetBean;
import com.rongshu.view.penpal.bean.PenpalArticleResponse;
import com.rongshu.view.userInfo.entity.Invitation;
import com.rongshu.view.userInfo.iview.InvitationView;

import rx.Subscriber;

public class InvitationPresenter extends BasePresenter<InvitationView> {

    public InvitationPresenter(Context context) {
        super(context);
    }

    /**
     * 我的帖子
     */
    public void getMyForum(int user_id, int page, int pagesize, String sign) {
        RetorfitService.getMyForum(user_id, page, pagesize, sign)
                .subscribe(new Subscriber<PenpalArticleResponse>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(PenpalArticleResponse invitation) {
                        if (getView() != null) {
                            getView().onInvitation(invitation);
                        }
                    }
                });
    }

    /**
     * 帖子删除
     */
    public void deletePenpalArticle(int user_id, int topic_id, int penpalwill_id, String sign) {
        RetorfitService.deletePenpalArticle(user_id, topic_id, penpalwill_id, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean iNetBean) {
                        if (getView() != null) {
                            getView().onDeletePenpalArticle(iNetBean);
                        }
                    }
                });
    }
}
